﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FuckData.DAO;
using FuckData.Model;
using FuckCore.BO;

namespace FuckData.BO
{
    public class AccountBO:BaseBO<AccountDAO,tbl_Account>
    {
        AccountDAO _AccountDAO = new AccountDAO();

        /// <summary>
        /// Create by DucND
        /// Datecreate 17/01/2014
        /// Check login of user
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public tbl_Account CheckLogin(string UserName, string Password)
        {
            string _Password = Common.FunctionUtil.GetMD5(Password);
            var Result = _AccountDAO.CheckLogin(UserName, _Password);
            if (Result == null)
                Result = new tbl_Account();
            return Result;
        }

        /// <summary>
        /// Check username is exist
        /// </summary>
        /// <param name="Username"></param>
        /// <returns></returns>
        public tbl_Account CheckUsername(string Username)
        {
            var Result = _AccountDAO.CheckUsername(Username);
            if (Result == null)
                Result = new tbl_Account();
            return Result;

        }

        /// <summary>
        /// Check email is exist
        /// </summary>
        /// <param name="Username"></param>
        /// <returns></returns>
        public tbl_Account CheckEmail(string Email)
        {
            var Result = _AccountDAO.CheckEmail(Email);
            if (Result == null)
                Result = new tbl_Account();
            return Result;

        }

        /// <summary>
        /// Get information of user by ID
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public tbl_Account GetActiveByID(long ID)
        {
            var Result = _AccountDAO.GetActiveByID(ID);
            if (Result == null)
                Result = new tbl_Account();
            return Result;
        }
    }
}
